﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_DeleteTreeBasicReferenceIDs')
	BEGIN
		DROP  Procedure  esf_sso.P_DeleteTreeBasicReferenceIDs
	END

GO

CREATE Procedure esf_sso.P_DeleteTreeBasicReferenceIDs
(
	@pParentID		INT
	,@pChildID		INT
	,@pID			INT	= NULL
)
AS

	IF @pID IS NOT NULL
	BEGIN
		
		DELETE FROM esf_sso.TreeBasicReference WHERE ID = @pID

	END
	ELSE
	BEGIN
		
		DELETE FROM esf_sso.TreeBasicReference 
		WHERE 
			ParentBasicReferenceID = @pParentID
			AND BasicReferenceID = @pChildID

	END

GO 